package TreeMap;

import java.util.TreeMap;

public class Test3 {
    public static void main(String[] args) {

        String str="abcdacdebaccabee";

        TreeMap<Character,Integer> tm=new TreeMap<>();

        for (int i = 0; i < str.length(); i++) {
            char c=str.charAt(i);
            if(tm.containsKey(c)){
                int num=tm.get(c);
                num++;
                tm.put(c,num);
            }
            else{
                tm.put(c,1);
            }
        }
        StringBuilder sb=new StringBuilder();
//        tm.forEach(new BiConsumer<Character, Integer>() {
//            @Override
//            public void accept(Character key, Integer value) {
//                sb.append(key).append("(").append(value).append(")");
//            }
//        });


        tm.forEach((key, value)-> sb.append(key).append("(").append(value).append(")"));


        System.out.println(sb);

    }
}
